/**
 * @file drv_hc595_pcu.c
 * @brief 
 * @author wangh (wanghuan3037@fiberhome.com)
 * @version 1.0
 * @date 2020-10-22
 * @copyright Copyright (c) 2020  烽火通信
 ***************************************************************
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version  <th>Author  <th>Description
 * <tr><td>2020-10-22 <td>1.0      <td>wangh   <td>内容
 * </table>
 */ 
#include "drv_hc595_pcu.h"
#include "project_board.h"

#undef LOG_LEVEL_
#define LOG_LEVEL_ 	LOG_LVL_ASSERT
#include "bsp_log.h"


static Hc595_t hc595_pwr;   ///< 智慧电源控制IO拓展

/**
 * @brief 电源输出控制初始化
 */
void drv_pwrCtr_init( void )
{
    HC595_Init( &hc595_pwr, POWER_CTRL_SCK, POWER_CTRL_RCK, POWER_CTRL_DATA );
}

/**
 * @brief 电源输出控制使能
 * @param  mask        PCU_XX_EN的组合
 * @param  state       0:置低，非0：置高
 * @par 示例:
 * @code
 *    drv_pwrCtr_Set( PCU_24V_EN | PCU_12VOUT1_EN | PCU_485_VCC1_EN );
 * @endcode
 */
void drv_pwrCtr_Set( uint8_t mask, uint8_t state )
{
    if( state == 0 )
        hc595_pwr.value &= ~mask;
    else
        hc595_pwr.value |= mask;

    HC595_SendByte( &hc595_pwr, hc595_pwr.value );
    HC595_Load( &hc595_pwr );
}

/**
 * @brief 获取电源输出当前状态
 */
void drv_pwrCtr_Get( uint8_t *mask )
{
    *mask = hc595_pwr.value;
}



/*********** (C) COPYRIGHT 2020 FiberHome *****END OF FILE****/
